package com.cpr.shop.controller;

import cn.hutool.core.util.StrUtil;
import com.cpr.shop.result.Result;
import com.cpr.shop.service.LoginService;
import com.cpr.shop.service.SmsService;
import com.cpr.shop.utils.VerifyCodeUtil;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import java.time.Duration;

import static com.cpr.shop.constant.RedisTimeoutConstant.TIMEOUT_FIVE_MINUTE;
import static com.cpr.shop.constant.UserRedisConstant.USER_LOGIN_CODE;

/**
 * @Author CPR
 * @Create 2025/1/23 22:13
 * @Version 1.0
 * @Description
 */
@ResponseBody
@Controller
@RequestMapping("api/shopping/v1/user")
@Slf4j
@CrossOrigin("*")
public class loginController {

    @Resource
    private LoginService loginServiceImpl;

    @Resource
    private StringRedisTemplate stringRedisTemplate;

    /**
     * 发送验证码
     * @param phone
     * @return
     */
    @GetMapping("sendCode/{phone}")
    public Result<Void> sendCode(@PathVariable("phone") String phone) {
        loginServiceImpl.sendCode(phone);
        return Result.success(null);
    }

    /**
     * 手机号登录
     * @return
     */
    public Result<Void> phoneLogin(){
        return Result.success(null);
    }
}
